/**
 * 将所有请求都挂载到传入的http上
 * 使用方法：
 * import api from '@/api'
 * api.enterprise.get()
 */
import enterprise from './enterprise'
import user from './user'

export default class Api {
  constructor(http) {
    this.http = http
    this.modules = {
      enterprise,
      user,
    }
  }
  use() {
    const api = {}
    for (const [name, module] of Object.entries(this.modules)) {
      api[name] = module(this.http)
    }
    return Object.assign(this.http, api)
  }
}
